#include "PclSurfacesModel.h"

#include "core/AppDirectory.h"

namespace {
const QString UserFilename = "pcl.sur_triangles.json";
}

PclSurfacesModel::PclSurfacesModel() {}

PclSurfacesModel& PclSurfacesModel::get()
{
    static PclSurfacesModel instance;
    if (instance.filename().isEmpty()) {
        instance.setFilename(AppDirectory::get().getAppDocFile(UserFilename));
        instance.load();
    }
    return instance;
}

void PclSurfacesModel::fromJson(const QJsonObject& json, QStringList& errorList)
{
    this->pcdFile_ = json["pcdFile"].toString();
}

QJsonObject PclSurfacesModel::toJson() const
{
    QJsonObject json = BaseDocument::toJson();
    json.insert("pcdFile", QJsonValue(this->pcdFile_));

    return json;
}
